home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
business
/
s3not10.zip
/
BIB.EDT
< prev
next >
Wrap
Text File
|
1992-09-14
|
10KB
|
280 lines
/*
******************************************
* Variable Declaration Section
******************************************
*/
typedef struct {
bool abort,
noneedited,
bypass,
edited,
finished,
fld_in_range;
int sno,
fno,
incy,
last_fld;
winptr winp,
edtwin;
} editGlobalVars;
typedef struct {
int sno,
fno,
incy;
winptr winp;
} dispGlobalVars;
editGlobalVars edt;
dispGlobalVars dsp;
/*
******************************************
* Function Declaration Section
******************************************
*/
void dspf(int x, int y, byte a, byte s, byte l, fldtyp *f)
{
dsp_fld((byte)x, (byte)(y + dsp.incy), f->faddr, f->typ, f->pic, s, l, a, dsp.winp);
}
/*************************************************************************/
void BIB_dsp(int fno, int sno, byte incy)
{
dsp.fno = fno;
dsp.sno = sno;
dsp.incy = incy;
dsp.winp = uw.wa[sno];
switch(sno) {
case 1 :
if (dsp.fno == 1) {
if (dsp.fno == filno) attrib = _av; else attrib = _iv;
dspf(19, 2,0,0,0,&BIB1._AUTHOR);
dspf(19, 3,0,0,0,&BIB1._TITLE);
dspf(19, 4,0,0,0,&BIB1._PUBLICATION);
dspf(19, 5,0,0,0,&BIB1._PUBLISHER);
dspf(19, 6,0,0,0,&BIB1._DATE);
dspf(19, 7,0,0,0,&BIB1._PAGES);
dspf(19, 9,0,0,0,&BIB1._KEY1);
dspf(19,10,0,0,0,&BIB1._KEY2);
dspf(19,11,0,0,0,&BIB1._KEY3);
dspf(45, 9,0,0,0,&BIB1._KEY4);
dspf(45,10,0,0,0,&BIB1._KEY5);
dspf(45,11,0,0,0,&BIB1._KEY6);
dspm(19,13,0,(byte)(dsp.sno),BIB1.datasize,&BIB1._MEMO,datf[ 1],dsp.winp);
}
break;
}
}
/*************************************************************************/
bool skipfield(int fnum)
{
bool tb;
tb = False;
if (edt.sno == 1) switch (fnum) {
case 0 : break;
}
return(tb);
}
/*************************************************************************/
bool chk_fld(int chknum)
{
string estr;
*estr = '\0';
if (edt.sno == 1) switch (chknum) {
case 0 : break;
}
if (*estr != '\0') {
audible(Error);
message(edt.winp, estr);
}
return (bool)(*estr == '\0');
}
/*************************************************************************/
void edt_n_chk(byte x, byte y, byte l, byte a, winptr h, fldtyp *f, int fldno)
{
if (!skipfield(fldno)) {
do {
if (!edt.bypass) {
edt_fld(x, y + edt.incy, f->faddr, f->typ, f->pic, l, a, edt.winp);
edt.noneedited = False;
edt.edited = True;
edt.abort = False;
if (exitcode == HlpKey) disphelp(h);
if (custom_key(scrno, edt.fno, &fldnum, &exitcode)) exitcode = QitKey;
}
if ((exitcode != QitKey) && (exitcode != UArr) && (exitcode != HlpKey)) {
edt.fld_in_range = chk_fld(fldno);
dsp_fld(x, y+edt.incy, f->faddr, f->typ, f->pic, 0, l, a, edt.winp);
if (!edt.fld_in_range) {
fldnum = fldno;
edt.bypass = False;
}
}
} while (!edt.fld_in_range && (exitcode != QitKey) && (exitcode != UArr));
message(NULL,"");
}
}
/*************************************************************************/
void openedtmnu(void)
{
string editHelpString;
strcpy(editHelpString, _EdtHelp);
if (openwin(0, (byte)(scrwid - strlen(editHelpString) + 1), scrhgt, (byte)(strlen(editHelpString)), 1, 0x4F, 0x4F, 0, "\0┐│┘─└│┌", TopCnt,"")) {
edt.edtwin = curwin;
writewxy(editHelpString, 0, 1, 1, edt.edtwin);
hidewin(T_ON, edt.edtwin);
}
else edt.edtwin = NULL;
}
/*************************************************************************/
void BIB_edt(int fno, int fld, int incy)
{
openedtmnu();
attrib = _av;
exitcode = Nul;
edt.fno = fno;
edt.sno = scrno;
edt.incy = incy;
edt.winp = uw.wa[edt.sno];
edt.abort = True;
edt.noneedited = True;
edt.bypass = False;
edt.finished = False;
fldnum = (fld == 0) ? 1 : fld;
do {
if (fldnum == 1) edt.noneedited = True;
if (edt_spos && (edt.last_fld != fldnum)) edt_spos = 1;
edt.last_fld = fldnum;
edt.edited = False;
if (edt.sno == 1) switch (fldnum) {
case 1 : if (edt.fno == 1) edt_n_chk(19, 2,0,0,hw.wa[1],&BIB1._AUTHOR,fldnum); break;
case 2 : if (edt.fno == 1) edt_n_chk(19, 3,0,0,hw.wa[2],&BIB1._TITLE,fldnum); break;
case 3 : if (edt.fno == 1) edt_n_chk(19, 4,0,0,hw.wa[3],&BIB1._PUBLICATION,fldnum); break;
case 4 : if (edt.fno == 1) edt_n_chk(19, 5,0,0,hw.wa[4],&BIB1._PUBLISHER,fldnum); break;
case 5 : if (edt.fno == 1) edt_n_chk(19, 6,0,0,hw.wa[5],&BIB1._DATE,fldnum); break;
case 6 : if (edt.fno == 1) edt_n_chk(19, 7,0,0,hw.wa[6],&BIB1._PAGES,fldnum); break;
case 7 : if (edt.fno == 1) edt_n_chk(19, 9,0,0,hw.wa[7],&BIB1._KEY1,fldnum); break;
case 8 : if (edt.fno == 1) edt_n_chk(19,10,0,0,hw.wa[7],&BIB1._KEY2,fldnum); break;
case 9 : if (edt.fno == 1) edt_n_chk(19,11,0,0,hw.wa[7],&BIB1._KEY3,fldnum); break;
case 10 : if (edt.fno == 1) edt_n_chk(45, 9,0,0,hw.wa[7],&BIB1._KEY4,fldnum); break;
case 11 : if (edt.fno == 1) edt_n_chk(45,10,0,0,hw.wa[7],&BIB1._KEY5,fldnum); break;
case 12 : if (edt.fno == 1) edt_n_chk(45,11,0,0,hw.wa[7],&BIB1._KEY6,fldnum); break;
case 13 : if ((edt.fno == 1) && !edt.bypass && !skipfield(fldnum)) {
edt.noneedited = False;
editmemo(19,13,0,BIB1.datasize,&BIB1._MEMO,
&BIB1,edt.winp,hw.wa[8],datf[ 1],&recno[ 1]); break;
}
default : if (edt.noneedited) {
edt.finished = True;
if (edt.abort) {
exitcode = QitKey;
dberrm(_NoneEdited);
}
}
else if (exitcode == XeptKey) edt.finished = True; else fldnum = 0;
}
if (edt.bypass || !edt.edited) {
if (_upward && (fldnum > 1)) fldnum--;
else fldnum++;
}
if (exitcode == XeptKey) edt.bypass = True;
if (exitcode == QitKey) edt.finished = True;
if (fldnum > edt.last_fld) _upward = False;
} while (!edt.finished);
if (edt.edtwin != NULL) closewin(&edt.edtwin);
}
/*************************************************************************/
void editdefaultdata(int fno, ptr fb)
{
byte lengthOfText,
lengthOfPrompt,
windowX,
windowY,
windowWidth,
windowHeight;
int fieldNumber,
saveFieldNumber;
winptr aWindowPtr;
fldblk *aFieldBlock;
fldtyp *aFieldType;
string tempString;
fldtyp editArray[23];
char colon[10];
strcpy(colon, " : ");
aFieldBlock = fb;
saveFieldNumber = fldnum;
lengthOfPrompt = lengthOfText = windowWidth = windowHeight = 0;
for (fieldNumber=0; fieldNumber < aFieldBlock->numf; fieldNumber++) {
windowHeight++;
aFieldType = &(*aFieldBlock->farr)[fieldNumber];
if (aFieldType->typ != _Memo && gvar->sec >= aFieldType->dsec && windowHeight < 23) {
if (strlen(aFieldType->fname) > lengthOfPrompt) lengthOfPrompt = strlen(aFieldType->fname);
if (strlen(aFieldType->faddr) > lengthOfText) lengthOfText = strlen(aFieldType->faddr);
memmove(&editArray[windowHeight], aFieldType, sizeof(fldtyp));
}
}
lengthOfPrompt = lengthOfPrompt + 3;
if ((lengthOfPrompt + lengthOfText) > (scrwid - 2)) lengthOfText = scrwid - 2 - lengthOfPrompt;
if (windowHeight > (scrhgt - 2)) windowHeight = scrhgt - 2;
windowWidth = lengthOfPrompt + lengthOfText;
windowX = (int)((scrwid - windowWidth) / 2);
windowY = (int)((scrhgt - windowHeight) / 2);
if (openwin(0, windowX, windowY, windowWidth, windowHeight, 15, 31, 8, "─┐│┘─└│┌", TopCnt, "")) {
aWindowPtr = curwin;
for (fieldNumber = 1; fieldNumber <= aFieldBlock->numf; fieldNumber++) {
aFieldType = &editArray[fieldNumber];
if (aFieldType->typ != _Memo && gvar->sec >= aFieldType->dsec) {
strcpy(tempString, aFieldType->fname);
strcat(tempString, colon);
writewxy(tempString, 0, 1, (byte)(fieldNumber), aWindowPtr);
dsp_fld(lengthOfPrompt + 1, fieldNumber, aFieldType->faddr, aFieldType->typ, aFieldType->pic, 0, lengthOfText, 0, aWindowPtr);
}
}
hidewin(T_ON, aWindowPtr);
fieldNumber = 1;
do {
aFieldType = &editArray[fieldNumber];
edt_fld(lengthOfPrompt + 1, fieldNumber, aFieldType->faddr, aFieldType->typ, aFieldType->pic, lengthOfText, 0, aWindowPtr);
if (_upward) fieldNumber--;
else fieldNumber++;
if (!fieldNumber) fieldNumber = windowHeight;
if (fieldNumber > windowHeight) fieldNumber = 1;
} while(exitcode != QitKey && exitcode != XeptKey);
closewin(&aWindowPtr);
}
fldnum = saveFieldNumber;
}